
$(document).ready(
	function()
	{
		$("a[tag='delete']").click( delete_review );

        //set current select options
     /*   $('#selsortby').val( $( "#sortby" ).val() );

        $('#selsortby').change(
            function(){
                var selected = $("#selsortby option:selected");
                //append the sortby and submit the form
                $( "#sortby" ).val( selected.val() );
                $( "#sortform" ).submit();
            }
        );*/
        
        var sortby = $( "#sortby" ).val();
        
        if(sortby == "review_date")         
       		$("#review_date").replaceWith('<span>'+$( "#review_date").text()+'</span>');
       		
        if(sortby == "response_count")         
       		$("#response_count").replaceWith('<span>'+$( "#response_count").text()+'</span>');
       		
        if(sortby == "flower_count")         
       		$("#flower_count").replaceWith('<span>'+$( "#flower_count").text()+'</span>');

        if(sortby == "score")         
       		$("#score").replaceWith('<span>'+$( "#score").text()+'</span>');
        
        $('.review_6').each(function(){
        	$(this).find('a').lightBox();
        });
       		

        //date picker
        /* Chinese initialisation for the jQuery UI date picker plugin. */
     /*   jQuery(function($){
            $.datepicker.regional['zh-CN'] = {
                closeText: '关闭',
                prevText: '&#x3c;上月',
                nextText: '下月&#x3e;',
                currentText: '今天',
                monthNames: ['一月','二月','三月','四月','五月','六月',
                '七月','八月','九月','十月','十一月','十二月'],
                monthNamesShort: ['一','二','三','四','五','六',
                '七','八','九','十','十一','十二'],
                dayNames: ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'],
                dayNamesShort: ['周日','周一','周二','周三','周四','周五','周六'],
                dayNamesMin: ['日','一','二','三','四','五','六'],
                dateFormat: 'yy-mm-dd', firstDay: 1,
                isRTL: false};
            $.datepicker.setDefaults($.datepicker.regional['zh-CN']);
        });
        $("#start_date").datepicker({ altField: '#actualDate', dateFormat: 'yy-mm-dd', changeMonth: true, changeYear: true });
		$("#end_date").datepicker({ dateFormat: 'yy-mm-dd', changeMonth: true, changeYear: true });

		//form validateion
		$("#filterform").validate({
			rules: {
				start_date: { date: true },
				end_date:{ date : true }
			},
			messages: {
				start_date: { date: "日期格式不正确" },
				end_date:{ date : "日期格式不正确" }
			},
			submitHandler: function(form) {
				return true;
			}
		});*/
	}
);

$(document).ready(function(){
 
   	$("#btnShowTag").toggle(function(){
   	    $("#hiddenTag").show();
   		$(this).removeClass("mr");
		$(this).addClass("lt");
		$(this).html("折起");
	},function(){
	   	$("#hiddenTag").hide();
   		$(this).removeClass("lt");   
		$(this).addClass("mr");
		$(this).html("显示更多");
	});     
	
	$("#btnShowCate").toggle(function(){
   	    $("#hiddenCate").show();
   		$(this).removeClass("mr");
		$(this).addClass("lt");
		$(this).html("折起");
	},function(){
	   	$("#hiddenCate").hide();
   		$(this).removeClass("lt");   
		$(this).addClass("mr");
		$(this).html("显示更多");
	});    
	   
});



function delete_review()
{
	var params = "rid=" + $(this).attr('rid');
	var rid = $(this).attr('rid');
	var reviewBlock = $(this).closest('.review_item');
	
	MessageBox( '此评论和相关的图片都会被删掉，确定要删除这个评论?', '删除评论', {
		yes : function(){
					$.ajax(
					{
						type: 'post',
						url: edp_domain_url + 'ajax_del_review/?tiny=2',
						data: params,
						timeout: 5000,
						global:false,
						beforeSend: function()
						{
							$.blockUI(
							{
								message: '正在删除...',
								css: {
									padding:'35px',
									color:'#CC0000'
								}
							});
						},
						error: function()
						{
							$.blockUI(
							{
								message: '删除失败(0)...',
								css: {
									padding:'35px',
									color:'#CC0000'
								}
							});
						},
						//success: function( data, textStatus )
						success: function( data )
						{
							/*
							if( data != "0" )
							{
								$.blockUI(
								{
									message: data,
									css: {
										padding:'35px',
										color:'#CC0000'
									}
								});
								setTimeout($.unblockUI, 2000);
							}
							else
							{
								setTimeout( $.unblockUI, 2000 );
								reviewBlock.css("display", "none");
							}
							*/
							$.blockUI(
									{
										message: data,
										css: { padding:'5px',color:'#CC0000'}
									});
						},
						 complete: function()
				            {
				            	$.unblockUI();
				            	window.location.reload();
				            }
					});
	},
	no : function(){UnblockUI();}
	});

}



